//
//  ConfigCodeHelper.h
//  Honda
//
//  Created by Xiaolong Zhang on 13-4-12.
//  Copyright (c) 2013年 HeninHoo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#define ServerURL       @"http://172.18.3.69/"

#define PadDataURL      [NSString stringWithFormat:@"http://%@/paddata/", [NetworkManager getInstance].host]

#define VersionsURL     [NetworkService_Server_DomainName stringByAppendingString:@"/Versions.aspx"]
#define MessageURL      [NetworkService_Server_DomainName stringByAppendingString:@"/Messages.aspx"]
#define EmailURL        [NetworkService_Server_DomainName stringByAppendingString:@"/Emails.aspx"]
#define SalersURL       [NetworkService_Server_DomainName stringByAppendingString:@"/Salers.aspx"]
#define PayTypesURL     [NetworkService_Server_DomainName stringByAppendingString:@"/PayTypes.aspx"]
#define LocalURL        [NetworkService_Server_DomainName stringByAppendingString:@"/GetServiceShopInfo.aspx"]
#define ComponentURL    [NetworkService_Server_DomainName stringByAppendingString:@"/SearchCompontentList.aspx"]

#define PredriveURL     [NSString stringWithFormat:@"http://%@/PadData/PadResourceFiles/RoadLine.jpg", [NetworkManager getInstance].host]
#define ComponentPicURL [NSString stringWithFormat:@"http://%@/PadData/PadResourceFiles/PartInfo/", [NetworkManager getInstance].host]
#define CurShopInfoURL  [NSString stringWithFormat:@"http://%@/PadData/PadResourceFiles/CurShopInfo/", [NetworkManager getInstance].host]//特约店介绍信息系列图片

#define APPUpdateURL    [NSString stringWithFormat:@"itms-services://?action=download-manifest&url=http://%@/PadData/GHAC_AfterSale/HondaPro_2.plist", [NetworkManager getInstance].host]

//#define PredriveURL     [NetworkService_Server_DomainName stringByAppendingString:@"/PadResourceFiles/RoadLine.jpg"]
//#define ComponentPicURL [NetworkService_Server_DomainName stringByAppendingString:@"/PadResourceFiles/PartInfo/"]
//#define CurShopInfoURL  [NetworkService_Server_DomainName stringByAppendingString:@"/PadResourceFiles/CurShopInfo/"]


#define kCodeKey        @"key"
#define kCodeValue      @"value"

#define kCodeArea       @"area"
#define kCodeSubarea    @"subArea"


#define writeToFile(dictionary, filePatn, ret) { \
NSOutputStream* output = [[NSOutputStream alloc] initToFileAtPath:(filePatn) append:NO];\
[output open];\
(ret) = [NSJSONSerialization writeJSONObject:(dictionary) toStream:output options:NSJSONWritingPrettyPrinted error:nil];\
[output close];\
[output release];\
}


enum paddataFileType {
    competing   = 0,
    company     = 1,
    serviceshop = 2,
    codeA       = 3,
    codeB       = 4,
    saleTechnique = 5
    };

enum universalFileType {
    version     =   0,
    message     =   1,
    email       =   2,
    salesman    =   3,
    client      =   4,
    shop        =   5,
    quality     =   6
    };

@interface ConfigCodeHelper : NSObject

@property (nonatomic, copy, readonly) NSString* padDataPath;//padData目录

@property (nonatomic, strong, readonly) NSMutableDictionary * sourceDic;//资源文件版本信息
@property (nonatomic, strong, readonly) NSDictionary* serviceShopDic;//特约店信息
@property (nonatomic, strong, readonly) NSDictionary* codeADic;//通用代码A
@property (nonatomic, strong, readonly) NSDictionary* codeBDic;//通用代码B

@property (nonatomic, strong, readonly) NSDictionary* messageDic;//短信模板
@property (nonatomic, strong, readonly) NSDictionary* emailDic;//邮件模板
@property (nonatomic, strong, readonly) NSDictionary* salersDic;//销售员
@property (nonatomic, strong, readonly) NSDictionary* paytypesDic;//支付方式
@property (nonatomic, strong, readonly) NSDictionary* localDic;//特约店
@property (nonatomic, strong, readonly) NSDictionary* componentDic;//精品信息

@property (nonatomic, strong, readonly) NSDictionary* remindDic;

/*
        key         des        type
    "customerID" 登记编号ID     string
    "name"        姓名         string
    "mobile"    手机          　string
    "address"   联系地址        string
    "certificate" 身份证号码　　　string
 */
@property (nonatomic, strong, readwrite)NSMutableDictionary* customerInfo;//当前客户信息

@property (nonatomic, assign, readonly) BOOL isVersonNeedUpdate;//app是否需要更新


+ (ConfigCodeHelper*)shareInstance;

- (void)updateSourceCarsFileByKey:(NSString*)key;

- (void)updataPadDataSourceByKey:(NSString*) key;

//--------------------------codeA--------------------
//证件类型ID_type
- (NSArray*)codeAIDType;

/*非级联的代码表使用接口
 客户来源:customer_source
 客户等级:customer_level
 客户性质:customer_property
 年龄段:age
 消息来源:sources
 性别:sex
 婚姻状况:marital_status
 职业:profession
 爱好:hobby
 购车性质:buy_car_state
 贷款方式:loans_mode
 下一步措施:next_work
 跟踪方式:track_mode
 提醒类型:alert_mode
 取消订单原因类型:cancel_order_reasons
 车辆库存状态:inventory_status
 精品来源:quality_sources
 */
- (NSArray*)codeASystematicsByPrimaryKey:(NSString*)pKey;
- (NSString*)codeAValueByPrimaryKey:(NSString*)pKey andSubKey:(NSString*)sKey;
- (NSString*)codeAKeyByPrimaryKey:(NSString*)pKey andSubValue:(NSString*)sValue;

/*-------------------------------------------------------------*/
/*级联的代码表：“所在地区:area”、“车辆厂家:car_shop”、“车辆品牌:brand”、“战败类型:defeated_type”、“战败原因:defeated_causes”*/
/*-------------------------------------------------------------*/
/*------------级联的代码表使用接口------------*/
//所在地区

/*codeAZoneByProvinceCode:andCityCode:获取指定的地区名称
 参数：
    province：省、直辖市的代码表
    city：市代码表
 返回：
    如果两个参数同时为空，返回所有省和直辖市的名称array
    如果city为空，返回province指定的城市array
    如果都不为空，返回province和city指定的所有区的名称array
*/
- (NSArray*)codeAZoneByProvinceCode:(NSString*)pCode andCityCode:(NSString*)cCode;
- (NSString*)codeAZoneByProvinceCode:(NSString*)pCode andCityCode:(NSString*)cCode andAreaCode:(NSString*)aCode;//获取指定地区名称

//车辆厂家、品牌
- (NSArray*)codeACarsByShopCode:(NSString*)sCode;
- (NSString*)codeACarByShopCode:(NSString*)sCode andBrandCode:(NSString*)bCode;
//战败类型、原因
- (NSArray*)codeAAllDefeatedType;//获取所有失败类型
- (NSString*)codeADefeatedByTypeCode:(NSString*)defeatedCode;//获取失败类型
- (NSArray*)codeAAllBuyOtherCarCauses;//获取所有购买其他厂家车辆的原因
- (NSString*)codeABuyOtherCarByCauseCode:(NSString*)causeCode;//获取购买其他厂家车辆原因
//------------------------end codeA------------------

// honda 车型信息
/*  车型：     cartype
    车身颜色：  outside
    内饰颜色：  inside
*/
- (NSDictionary *)carinfosFromCarclassKey:(NSString *)carclassKey cartypeKey:(NSString *)cartypeKey outsideColorKey:(NSString *)outsideColorKey insideColorKey:(NSString *)insideColorKey;

// 获取信息渠道
- (NSString *)stringFromMessageSource:(NSString *)messageSource otherSource:(NSString *)otherSource;
- (NSArray *)keysArrayFromMessageSource:(NSString *)messageSource;
- (BOOL)containOhterSourceInKeysArray:(NSArray *)keysArray;
- (BOOL)containOhterSourceInMessageSource:(NSString *)messageSource;
- (NSString *)messageSourceFromkeysArray:(NSArray *)keysArray;

// 兴趣爱好
- (NSString *)stringFromHobbies:(NSString *)hobbies;
- (NSArray *)hobbykeysFromHobbies:(NSString *)hobbies;
- (NSString *)hobbiesFromHobbykeys:(NSArray *)hobbykeys;

// 所在地
- (NSString *)locationStringByProvinceCode:(NSString*)pCode andCityCode:(NSString*)cCode andAreaCode:(NSString*)aCode;

//短信模板代码表转换
-(NSMutableArray*)getModelCode;

//按照id查找对应的模板对象
-(NSString*)getModelContentByKey:(NSString*)str;

//邮件模板代码表转换
-(NSMutableArray*)getEmailModelCode;

//按照id查找对应的邮件模板对象信息
- (NSDictionary*)getEmailModelDictionaryByKey:(NSString*)str;
////按照id查找对应的邮件模板对象
//-(NSString*)getEmailModelContentByKey:(NSString*)str;

//按照salerID查找对应的salerName
-(NSString*)getSalerNameByKey:(NSString*)salerID;
@property(retain,nonatomic)NSString *panduanString;
@end